package com.geekstudy.week4.proxy;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class DemoDynamicProxy implements InvocationHandler {

    final Logger logger = LoggerFactory.getLogger(DemoDynamicProxy.class);

    private Object target;

    public DemoDynamicProxy(Object target) {
        this.target = target;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        logger.info("invoke start");
        Object result = method.invoke(target, args);
        logger.info("invoke finish result:{}", result);
        return result;
    }


}
